home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48_2 / strip < prev    next >
Internet Message Format  |  1995-03-31  |  8KB

  1. From comp.sys.handhelds Tue Jan 22 12:03:40 1991
  2. Path: mentor.cc.purdue.edu!noose.ecn.purdue.edu!samsung!know!news.cs.indiana.edu!msi.umn.edu!noc.MR.NET!gacvx2.gac.edu!hhdist
  3. From: CW%APG.PH.UCL.AC.UK@pucc.PRINCETON.EDU
  4. Newsgroups: comp.sys.handhelds
  5. Subject: <None>
  6. Message-ID: <4B9CED9060006598@gacvx2.gac.edu>
  7. Date: 22 Jan 91 15:56:50 GMT
  8. Lines: 200
  9. To: HANDHELDS@gac.edu
  10. Return-path: <@pucc.PRINCETON.EDU:CW@APG.PH.UCL.AC.UK>
  11. To: HANDHELDS@gac.edu
  12. Via:      UK.AC.UCL.PH.APG; 21 JAN 91 12:06:16 GMT
  13.  
  14.  
  15.      Hi everybody,
  16.        This message contains three bits ,i) an apology ii) an explanation
  17.      iii) a couple of routines and iv) a thankyou, sorry this massage
  18.      contains four bits,i) an apology ii) an explanation iii) a couple of
  19.      routines and iv) a thankyou oh and v), ah damn it, start again, this
  20.      massage contains five bits, i) an apology ii) an explanation iii) a couple
  21.      of routines,iv) a thankyou and v) an apology for being so silly at the
  22.      beginning of this posting.
  23.  
  24.      i) I'm sorry I can not put a subject header on my posting because
  25.         of the software we are using at my end (its hard enough to actually
  26.         post this). So for the man who wants to know what this is for (I
  27.         actually think its a very reasonable request) this posting is
  28.         for
  29.  
  30.                HP48SX (the routines were written on a version D machine
  31.                        please let me know if they fail on other versions).
  32.  
  33.      ii) It appears that (sorry more waffle) for a while now I have been
  34.          posting my messages to the wrong place, and not everybody (infact
  35.          not many people atall I think) have been receiving my messages.
  36.          I am therefore posting again my two most recent routines. I
  37.          apologise to anyone receiving these once more, but I'd like
  38.          them to get onto c.s.h.... Thankyou to Dan Boehlke for informing
  39.          me of my misdirection and sending back my mail so I can
  40.          reduce the amount of retyping. It actually means that I have
  41.          tidied up the presentation a bit. (that the thankyou otu of the way
  42.          so no part iv) !!)
  43.  
  44.      iii) In the latest  edition of DATAFILE (the journal of the Handheld
  45.           and Portable Computer Club) there was an excellent article
  46.           by Stephen J. Thomas, which inspired me to write these routines for
  47.           the HP48.
  48.           The begin and end program markers (<< and >>) are not infact
  49.           necessary on a completed program that does not need to be edited.
  50.           They act as markers to tell the calculator not to execute
  51.           commands as they are entered but rather save them until
  52.           the whole lot within the markers is used as a program.
  53.  
  54.  
  55.           e.g. If you have an empty stack and press + you get
  56.                 + error: too few arguaments. However if you press
  57.                'left-shift' <<>> + ENTER you get the program << + >>
  58.                on the first level of the stack. The <<>> have prevented
  59.                the + from being executed immediately. The important thing
  60.                is that the fact that the + is in a program is not
  61.                due to it being surrounded by the <<>> but that the object
  62.                has a prolog header 02d9dh which means it is a program (type
  63.                8). If you use ->ASC on << + >> you get
  64.  
  65.                "D9D20E163276BA193632B21304710"
  66.  
  67.                Which if unthreaded becomes,
  68.  
  69.                02D9D      PROGRAM BEGIN (This makes it type 8)
  70.                2361E      <<
  71.                1AB67      +
  72.                23639      >>
  73.                0312B      END MARKER (In this case end program)
  74.                0147       Checksum
  75.  
  76.                Amazingly enough this is equivalent to
  77.  
  78.                02D9D      PROGRAM BEGIN
  79.                1AB67      +
  80.                0312B      END
  81.                FFB5       Checksum
  82.  
  83.                Differing only in the fact that you can not edit it
  84.              (without those markers when you finish the edit the calculator
  85.               will try to execute the commands immediately) and it takes
  86.               5 less bytes. Oh and also on the stack you would no longer
  87.               see the <<>>. Try
  88.  
  89.               "D9D2076BA1B21305BFF"  ASC->
  90.  
  91.               you get
  92.  
  93.               1:              +
  94.  
  95.               If you do TYPE you get 8 which shows it is considered
  96.               a program. (Note if you do $ +  OBJ-> the + on the
  97.               stack returns type 18 which means it is considered
  98.               as a built in command)
  99.  
  100.         What this all means is that once a program is finished
  101.         you can remove the <<>> around it and save five bytes. I know
  102.         this is not alot but used in conjuction with Joseph Horn's
  103.         PACK routine, it just adds that little extra saving. One day
  104.         you might be desparate for memory and stripping all the <<>>'s
  105.         from your programs just might save the day.... Any way
  106.         I now give a routine, one called STRIP and , aah I give
  107.         two routines (;-)) one called STRIP which removes the <<>>'s
  108.         from around any program in level 1 of the stack. And one called
  109.         DRESS which puts the <<>>'s back on a program object in level 1:
  110.         just incase you want to edit it later. STRIP is very small small
  111.         (17.5 bytes) but unstrip is a bit bigger (49), can anybody make it
  112.         smaller ( I found it was difficult to get the << >> separately on the
  113.         stack).
  114.  
  115.  
  116.        PROGRAM: STRIP
  117.        ACTION: 1: Program with <<>> delimiters -> 1: Program without
  118.                                                      <<>> delimiters
  119.  
  120.        eg
  121.  
  122.        \<< SIN +  \>>     STRIP
  123.  
  124.      will produce
  125.  
  126.            SIN +
  127.  
  128.  
  129.      ROUTINE:
  130.  
  131.          <<
  132.                #54afh SYSEVAL               @Explode composite object
  133.                #3e4eh SYSEVAL               @Subtract two from SB at level 1
  134.                #60f9bh SYSEVAL              @Drop level 2 object
  135.                #5445h SYSEVAL               @Build program
  136.                #60f9bh SYSEVAL              @Drop level 2 object
  137.          >>
  138.  
  139.       Check: 5230h
  140.  
  141.       In this form it is editible but takes up 87.5 bytes.
  142.  
  143.          Type in the above routine and store it in a variable called
  144.       STRIP. The do 'STRIP' RCL PACK STRIP 'STRIP' STO. STRIP will now
  145.       look like (pack is Joseph Horns routine)
  146.  
  147.                     External External
  148.                     External <2d9dh>
  149.                     External External
  150.  
  151.  
  152.  
  153.  
  154. PROGRAM: UNSTRIP
  155. ACTION: Program without <<>> delims -> Program with <<>> delims
  156.  
  157.         e.g.   1:         SIN +
  158.        becomes
  159.                1:      << SIN + >>
  160.  
  161.  
  162.     <<
  163.          #54afh SYSEVAL
  164.          #3e2dh SYSEVAL
  165.          <<   >>                          @empty program delimiters in
  166.                                            side program.
  167.          #54afh SYSEVAL
  168.          #3244h SYSEVAL
  169.          #3223h SYSEVAL
  170.          #611feh SYSEVAL
  171.          #3defh SYSEVAL
  172.          #339eh SYSEVAL
  173.          #3223h SYSEVAL
  174.          #5445h SYSEVAL
  175.      >>
  176.  
  177.  
  178.      This does the reverse of the stripper i.e.
  179.  
  180.           an unstripped program such as
  181.  
  182.           SIN COS +
  183.  
  184.           becomes
  185.  
  186.           << SIN COS + >>
  187.  
  188.     snd you can then edit this normally and then strip it again.
  189.  
  190.     in this form it takes 189 bytes and has checksum #9a56h (seeing as
  191. theres
  192.     a lot of sysevals it seems sensible to give this). If you use
  193.     J.K.Horns Pack routine and my strip routine it reduces to 54 bytes
  194.     and #7200h as its checksum.
  195.  
  196.          WARNING: THESE ROUTINES DO NO ERROR CHECKING
  197.                   THEY BEHAVE ERRATICALLY WHEN ANYTHING
  198.                   OTHER THAN A PROGRAM IS ON LEVEL 1 OF THE
  199.                   STACK.
  200.  
  201.          DISCLAIMER: Anything that happens as a result of these
  202.                      routines is not my responsibility.
  203.  
  204.  
  205.  iv) Another thankyou. Thankyou to the people who have so bravely
  206.      laid down the memory of their calculators in the search for the lost
  207.      entry point.
  208.  
  209.   v) Sorry for being so silly at the beginning of this posting.
  210.  
  211.       Regards and enjoy and explore
  212.  
  213.       Conrad winchester.
  214.  
  215.